library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(tidyr)
library(readr)
library(stringr)
library(ggplot2)
library(ggrepel)
library(topr)
library(UpSetR)
library(plyranges)
## Loading required package: BiocGenerics
## 
## Attaching package: 'BiocGenerics'
## The following objects are masked from 'package:dplyr':
## 
##     combine, intersect, setdiff, union
## The following objects are masked from 'package:stats':
## 
##     IQR, mad, sd, var, xtabs
## The following objects are masked from 'package:base':
## 
##     anyDuplicated, aperm, append, as.data.frame, basename, cbind,
##     colnames, dirname, do.call, duplicated, eval, evalq, Filter, Find,
##     get, grep, grepl, intersect, is.unsorted, lapply, Map, mapply,
##     match, mget, order, paste, pmax, pmax.int, pmin, pmin.int,
##     Position, rank, rbind, Reduce, rownames, sapply, saveRDS, setdiff,
##     table, tapply, union, unique, unsplit, which.max, which.min
## Loading required package: IRanges
## Warning: package 'IRanges' was built under R version 4.4.2
## Loading required package: S4Vectors
## Loading required package: stats4
## 
## Attaching package: 'S4Vectors'
## The following object is masked from 'package:tidyr':
## 
##     expand
## The following objects are masked from 'package:dplyr':
## 
##     first, rename
## The following object is masked from 'package:utils':
## 
##     findMatches
## The following objects are masked from 'package:base':
## 
##     expand.grid, I, unname
## 
## Attaching package: 'IRanges'
## The following objects are masked from 'package:dplyr':
## 
##     collapse, desc, slice
## Loading required package: GenomicRanges
## Loading required package: GenomeInfoDb
## Warning: package 'GenomeInfoDb' was built under R version 4.4.2
## 
## Attaching package: 'plyranges'
## The following object is masked from 'package:IRanges':
## 
##     slice
## The following objects are masked from 'package:dplyr':
## 
##     between, n, n_distinct
## The following object is masked from 'package:stats':
## 
##     filter
library(ieugwasr)
## OpenGWAS updates:
##   Date: 2024-05-17
##   [>] OpenGWAS is growing!
##   [>] Please take 2 minutes to give us feedback -
##   [>] It will help directly shape our emerging roadmap
##   [>] https://forms.office.com/e/eSr7EFAfCG
library(gwascat)
## gwascat loaded.  Use makeCurrentGwascat() to extract current image.
##  from EBI.  The data folder of this package has some legacy extracts.
# Source helper functions 
source("multi_funcs.R")

Principal components

plot_ancestry_PCs("antidep-2501-mrmega-N06A.log")

plot_ancestry_PCs("antidep-2501-mrmega-N06AA.log")

plot_ancestry_PCs("antidep-2501-mrmega-N06AB.log")

Manhattan plots

mrmega_n06a <- get_sumstats("antidep-2501-mrmega-N06A-DIV.gz")
## Rows: 10650849 Columns: 29
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: "\t"
## chr  (5): MarkerName, EA, NEA, Effects, CHR
## dbl (23): Chromosome, Position, EAF, Nsample, Ncohort, beta_0, se_0, beta_1,...
## lgl  (1): Comments
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
mrmega_n06aa <- get_sumstats("antidep-2501-mrmega-N06AA-DIV.gz")
## Rows: 9007284 Columns: 29
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: "\t"
## chr  (5): MarkerName, EA, NEA, Effects, CHR
## dbl (23): Chromosome, Position, EAF, Nsample, Ncohort, beta_0, se_0, beta_1,...
## lgl  (1): Comments
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
mrmega_n06ab <- get_sumstats("antidep-2501-mrmega-N06AB-DIV.gz")
## Rows: 10033491 Columns: 29
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: "\t"
## chr  (5): MarkerName, EA, NEA, Effects, CHR
## dbl (23): Chromosome, Position, EAF, Nsample, Ncohort, beta_0, se_0, beta_1,...
## lgl  (1): Comments
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
mrmega_n06a_assoc <- get_assoc(mrmega_n06a, "N06A")
mrmega_n06aa_assoc <- get_assoc(mrmega_n06aa, "N06AA")
mrmega_n06ab_assoc <- get_assoc(mrmega_n06ab, "N06AB")
plot_manhat(mrmega_n06a_assoc)

plot_manhat(mrmega_n06aa_assoc)

plot_manhat(mrmega_n06ab_assoc)

Clumps

clumps_N06A <- get_clumps("antidep-2501-mrmega-N06A-DIV.clumps.tsv")
## Rows: 26 Columns: 32
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: "\t"
## chr  (5): MarkerName, EA, NEA, Effects, CHR
## dbl (26): Locus, Chromosome, Position, EAF, Nsample, Ncohort, beta_0, se_0, ...
## lgl  (1): Comments
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
clumps_N06AA <- get_clumps("antidep-2501-mrmega-N06AA-DIV.clumps.tsv")
## Rows: 2 Columns: 32
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: "\t"
## chr  (4): MarkerName, EA, NEA, Effects
## dbl (27): Locus, Chromosome, Position, EAF, Nsample, Ncohort, beta_0, se_0, ...
## lgl  (1): Comments
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
clumps_N06AB <- get_clumps("antidep-2501-mrmega-N06AB-DIV.clumps.tsv")
## Rows: 6 Columns: 32
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: "\t"
## chr  (5): MarkerName, EA, NEA, Effects, CHR
## dbl (26): Locus, Chromosome, Position, EAF, Nsample, Ncohort, beta_0, se_0, ...
## lgl  (1): Comments
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
clumps_N06A
clumps_N06AA
clumps_N06AB

Catalogue

gwcat <- get_cached_gwascat()

gwascat_N06A_table <- look_up_snps(clumps_N06A, gwcat)
gwascat_N06AA_table <- look_up_snps(clumps_N06AA, gwcat)
gwascat_N06AB_table <- look_up_snps(clumps_N06AB, gwcat)

write.csv(gwascat_N06A_table, "multi_files/gwas_cat_N06A_table.csv", quote = F, row.names = F)
write.csv(gwascat_N06AA_table, "multi_files/gwas_cat_N06AA_table.csv", quote = F, row.names = F)
write.csv(gwascat_N06AB_table, "multi_files/gwas_cat_N06AB_table.csv", quote = F, row.names = F)